<?php

/**
 * authentication actions.
 *
 * @package    movilRedcol
 * @subpackage authentication
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class authenticationActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
    
    
  public function executeEVoucher(sfWebRequest $request)
  {
     $usuarioActual = $this->getUser()->getAttribute(sfConfig::get('app_name_session'),null);
     if($usuarioActual!=null)
     {
          $this->redirect('@selectOptionEvoucher');  
     }
     return sfView::SUCCESS;
  }
  
  public function executeLogOut(sfWebRequest $request)
  {
      $serviceAuthenticationEVoucher = new authenticationEVoucherClass();
      $serviceAuthenticationEVoucher->logOut();
      $this->redirect('@homepage');
  }
  
  public function executeAuthenticationEVoucher(sfWebRequest $request)
  {
    /*Verifico que la data sea enviada por post */ 
    $this->forward404Unless($request->isMethod('post'));
    $serviceAuthenticationEVoucher = new authenticationEVoucherClass();
    $user       =  $request->getParameter('user');
    $password   =  $request->getParameter('password');    
    $paramArray = array("user"=>$user, "password" => $password);
    $respuestaLogin =  $serviceAuthenticationEVoucher->logInEVoucher($paramArray);    
    
   
    if($respuestaLogin['success'])
    {
      $this->redirect('@selectOptionEvoucher');  
    }
    else
    {
      $this->getUser()->setFlash('s_login_error', true);
      $this->redirect('@logInAuthenticationEVoucher');
    }
    
  }
  
  
}
